//
// ***********************************************
// *    ___________   ___________  __      __    *
// *   |______  __/  /_____  ___/  \ \    / /    *
// *         / /          / /       \ \  / /     *
// *        / /          / /         \ \/ /      *
// *       / /          / /           \  /       *
// *      / /______    / /            / /        *
// *     /________/   /_/            /_/         *
// *                                             *
// ***********************************************
//
//   TableTestViewController.m
//   InterviewDemo
//   
//   Created  by wanmeizty on 25/12/2019
//   Modified by Tiyon  qq 897574226  
//   Copyright © 2019 wanmeizty. All rights reserved.
//   
   

#import "TableTestViewController.h"

@interface TableTestViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation TableTestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UITableView * tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.rowHeight = 30;
    [self.view addSubview:tableView];
    // Do any additional setup after loading the view.
}

//设置section的个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    NSLog(@"%@",NSStringFromSelector(_cmd));
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    NSLog(@"%@--%ld",NSStringFromSelector(_cmd),section);
    
    return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    NSLog(@"%@--%@",NSStringFromSelector(_cmd),indexPath);
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%@--%@",NSStringFromSelector(_cmd),indexPath);
    return 200;
}

- (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    NSLog(@"%@--%ld",NSStringFromSelector(_cmd),section);
    return @"headerTitle";
}
- (nullable NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
    NSLog(@"%@--%ld",NSStringFromSelector(_cmd),section);
    return @"footerTitle";
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"%@--%@",NSStringFromSelector(_cmd),indexPath);
}
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
    NSLog(@"%@--%ld",NSStringFromSelector(_cmd),section);
}
- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section {
    NSLog(@"%@--%ld",NSStringFromSelector(_cmd),section);
}
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath {
    NSLog(@"%@--%@",NSStringFromSelector(_cmd),indexPath);
}
- (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section {
    NSLog(@"%@--%ld",NSStringFromSelector(_cmd),section);
}
- (void)tableView:(UITableView *)tableView didEndDisplayingFooterView:(UIView *)view forSection:(NSInteger)section {
    NSLog(@"%@--%ld",NSStringFromSelector(_cmd),section);
}

// Variable height support

//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
//    NSLog(@"%@--%@",NSStringFromSelector(_cmd),indexPath);
//    return 50;
//}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    NSLog(@"%@---%ld",NSStringFromSelector(_cmd),section);
    return 30;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    NSLog(@"%@--%ld",NSStringFromSelector(_cmd),section);
    return 10;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    NSLog(@"%@--%ld",NSStringFromSelector(_cmd),section);
    UILabel *label = [[UILabel alloc] init];
    label.text = @"头标题";
    return label;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    NSLog(@"%@--%ld",NSStringFromSelector(_cmd),section);
    UILabel *label = [UILabel new];
    label.text = @"尾标题";
    return label;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
